//
//  SolarEntity.swift
//  SimpleCal
//
//  Created by 杜晓祥 on 2021/10/19.
//

import Foundation

struct  SolarEntity:CustomStringConvertible {
    
    var  year:Int = 0
    var  month:Int = 0
    var  day:Int = 0
    var  week:Int = 0
    var  weekOfMonth:Int = 0
    var  weekOfYear:Int = 0
    var  hour:Int = 0
    var  minute:Int = 0
    var  second = 0
    var  date:Date

    init() {
        self.date = Date()
    }
    var description: String {
        return self.dateFormatter(formatter: "yyyy年MM月dd日，HH时mm分ss秒") + ",周\(week),今年第\(weekOfYear)周,本月第\(weekOfMonth)周"
    }
}
extension SolarEntity {
    
    func formatterYearMonthDay () -> String {
        return  CalendarUtil.getFormatter(formatter: CalendarUtil.DATE_FORMATTER, date: self.date)
    }
    
    func dateFormatter(formatter:String) -> String {
        return CalendarUtil.getFormatter(formatter: formatter, date: self.date)
    }
    
    func dateYearMonthZH () -> String {
        return CalendarUtil.getFormatter(formatter: CalendarUtil.CN_YEAR_MONTH, date: self.date)
    }
    
    /**
     返回周几，格式为周一，周二，周三。。。
     */
    func getSimpleWeek () -> String {
        return CalendarUtil.getWeekStr(week: self.week, pre: "周")
    }

    /**
     判断当前时间是否为周末
     */
    func isWeek () -> Bool {
        return self.week == 1 || self.week == 7
    }
    
}

